import request from '@/utils/request'

// 获取医院列表
export function getHospitals(params) {
  return Promise.resolve({
    code: 200,
    data: [
      { id: 1, name: '市第一人民医院', address: 'XX区XX路1号', level: '三甲', department_count: 30 },
      { id: 2, name: '市第三附属医院', address: 'XX区XX路2号', level: '三甲', department_count: 25 },
      { id: 3, name: '市中心医院', address: 'XX区XX路3号', level: '二甲', department_count: 20 },
    ]
  })
  // return request({
  //   url: '/medical/hospitals',
  //   method: 'get',
  //   params
  // })
}

// 获取科室列表
export function getDepartments(hospitalId) {
  return Promise.resolve({
    code: 200,
    data: [
      { id: 101, name: '内科' },
      { id: 102, name: '外科' },
      { id: 103, name: '儿科' },
      { id: 104, name: '妇产科' },
      { id: 105, name: '骨科' },
    ]
  })
  // return request({
  //   url: `/medical/hospitals/${hospitalId}/departments`,
  //   method: 'get',
  // })
}

// 获取医生列表
export function getDoctors(departmentId) {
  const mockDoctors = {
    101: [
      { id: 201, name: '张医生', title: '主任医师', specialty: '心血管内科', schedule: '周一、周三上午', fee: 50 },
      { id: 202, name: '李医生', title: '主治医师', specialty: '呼吸内科', schedule: '周二、周四下午', fee: 30 },
    ],
    102: [
      { id: 203, name: '王医生', title: '主任医师', specialty: '普外科', schedule: '周一、周五上午', fee: 50 },
      { id: 204, name: '赵医生', title: '副主任医师', specialty: '神经外科', schedule: '周三下午、周六上午', fee: 40 },
    ],
    // ... 更多科室的医生数据
  }
  return Promise.resolve({
    code: 200,
    data: mockDoctors[departmentId] || []
  })
  // return request({
  //   url: `/medical/departments/${departmentId}/doctors`,
  //   method: 'get',
  // })
}

// 创建预约
export function createAppointment(data) {
  return Promise.resolve({
    code: 200,
    message: '预约成功',
    data: { order_id: 'APPT' + Date.now(), ...data }
  })
  // return request({
  //   url: '/medical/appointments',
  //   method: 'post',
  //   data
  // })
}

// 获取医疗订单列表
export function getMedicalOrders(params) {
  const mockOrders = [
    { id: 1, order_id: 'MD2024001', hospital_name: '市第一人民医院', doctor_name: '张医生', appointment_time: '2024-06-15 10:00', amount: 120.00, status: 'pending_payment' },
    { id: 2, order_id: 'MD2024002', hospital_name: '市第三附属医院', doctor_name: '李医生', appointment_time: '2024-06-10 14:30', amount: 80.00, status: 'completed' },
    { id: 3, order_id: 'MD2024003', hospital_name: '市中心医院', doctor_name: '王医生', appointment_time: '2024-06-08 09:00', amount: 200.00, status: 'pending_payment' },
  ];
  const { page = 1, per_page = 10 } = params;
  const start = (page - 1) * per_page;
  const end = start + per_page;

  return Promise.resolve({
    code: 200,
    data: {
      items: mockOrders.slice(start, end),
      total: mockOrders.length,
    }
  });
  // return request({
  //   url: '/medical/orders',
  //   method: 'get',
  //   params
  // })
}

// 结算医疗订单
export function settleMedicalOrder(orderId, paymentType) {
  return Promise.resolve({
    code: 200,
    message: '订单结算成功',
  })
  // return request({
  //   url: `/medical/orders/${orderId}/settle`,
  //   method: 'post',
  //   data: { payment_type: paymentType }
  // })
} 